package com.movitech.mobile.cz.base.purchase.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.movitech.mobile.cz.base.purchase.entity.PSpPlanDetail;
import com.movitech.mobile.cz.base.purchase.entity.ext.ExtPSpPlanDetail;
import com.movitech.mobile.cz.base.purchase.entity.ext.StrategicPurchaseRequiredFindRequest;
import com.movitech.mobile.cz.base.purchase.mapper.PSpPlanDetailMapper;
import com.movitech.mobile.cz.base.purchase.mapper.ext.ExtPSpPlanDetailMapper;
import com.movitech.mobile.cz.base.purchase.service.PSpPlanDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 战略采购规划-需求明细 服务实现类
 * </p>
 *
 * @author Movitech Mobile
 * @since 2018-03-15
 */
@Service
public class PSpPlanDetailServiceImpl extends ServiceImpl<PSpPlanDetailMapper, PSpPlanDetail> implements PSpPlanDetailService {
    @Autowired
    private ExtPSpPlanDetailMapper extPSpPlanDetailMapper;
    @Override
    public List<PSpPlanDetail> getDetailsByYear(Integer year) {
        return extPSpPlanDetailMapper.findListsByYear(year);
    }

    @Override
    public Integer selectExtCount(StrategicPurchaseRequiredFindRequest strategicPurchaseRequiredFindRequest) {
        return extPSpPlanDetailMapper.findExtCount(strategicPurchaseRequiredFindRequest);
    }

    @Override
    public List<ExtPSpPlanDetail> selectExtByEntity(StrategicPurchaseRequiredFindRequest strategicPurchaseRequiredFindRequest) {
        return extPSpPlanDetailMapper.findByRequestEntity(strategicPurchaseRequiredFindRequest);
    }

    @Override
    public boolean deleteByStrategicId(String sId) {
        PSpPlanDetail pSpPlanDetail = new PSpPlanDetail();
        pSpPlanDetail.setStrategicPurchasePlanId(sId);
        EntityWrapper entityWrapper = new EntityWrapper();
        entityWrapper.setEntity(pSpPlanDetail);
        return delete(entityWrapper);
    }
}

